package com.meilai.project.controller.web.system;


import com.meilai.project.dto.CommonResult;
import com.meilai.project.entity.system.MediaTypeSpecPrice;
import com.meilai.project.service.system.MediaTypeSpecPriceService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 点位类型-规格-价格 前端控制器
 * </p>
 *
 * @author haiYangX
 * @since 2022-05-28
 */
@RestController
@RequestMapping("/api/web/mediaTypeSpecPrice")
public class MediaTypeSpecPriceController {

    @Autowired
    private MediaTypeSpecPriceService mediaTypeSpecPriceService;

    @GetMapping("/list")
    @ApiOperation("列表")
    public CommonResult list(@RequestParam(value = "page", defaultValue = "1") Integer page,
                             @RequestParam(value = "page_size", defaultValue = "10") Integer page_size,
                             @RequestParam(value = "media_type_spec_id") Long media_type_spec_id) {
        return new CommonResult().success(mediaTypeSpecPriceService.list(page, page_size, media_type_spec_id));
    }

    @GetMapping("/allList")
    @ApiOperation("列表")
    public CommonResult list(@RequestParam(value = "media_type_spec_id") Long media_type_spec_id) {
        return new CommonResult().success(mediaTypeSpecPriceService.list(media_type_spec_id));
    }

    @PostMapping("/add")
    @ApiOperation("添加")
    public CommonResult add(@RequestBody MediaTypeSpecPrice mediaTypeSpecPrice) {
        return new CommonResult().success(mediaTypeSpecPriceService.save(mediaTypeSpecPrice));
    }


    @PostMapping("/edit")
    @ApiOperation("修改")
    public CommonResult edit(@RequestBody MediaTypeSpecPrice mediaTypeSpecPrice) {
        return new CommonResult().success(mediaTypeSpecPriceService.updateById(mediaTypeSpecPrice));
    }

    @DeleteMapping("/remove")
    @ApiOperation("删除")
    public CommonResult remove(@RequestParam(value = "id") Long id) {
        return new CommonResult().success(mediaTypeSpecPriceService.removeById(id));
    }

    @GetMapping("/all")
    @ApiOperation("列表")
    public CommonResult allList() {
        return new CommonResult().success(mediaTypeSpecPriceService.allList());
    }


}
